import request from "@/utils/request";

export function login(username, password) {
  return request({
    url: "http://127.0.0.1:8000/user/login/",
    method: "post",
    data: {
      username,
      password,
      // mobile,
    }
  });
}

export function getInfo(name) {
  return request({
    url: "http://127.0.0.1:8000/user/info/",
    method: "get",
    params: { name: name }
  });
}

export function logout() {
  return request({
    url: "http://127.0.0.1:8000/user/logout/",
    method: "post"
  });
}

export function fetchList(params) {
  return request({
    url: "/admin/list",
    method: "get",
    params: params
  });
}

export function createAdmin(data) {
  return request({
    url: "/admin/register",
    method: "post",
    data: data
  });
}

export function updateAdmin(id, data) {
  return request({
    url: "/admin/update/" + id,
    method: "post",
    data: data
  });
}

export function updateStatus(id, params) {
  return request({
    url: "/admin/updateStatus/" + id,
    method: "post",
    params: params
  });
}

export function deleteAdmin(id) {
  return request({
    url: "/admin/delete/" + id,
    method: "post"
  });
}

export function getRoleByAdmin(id) {
  return request({
    url: "/admin/role/" + id,
    method: "get"
  });
}

export function allocRole(data) {
  return request({
    url: "/admin/role/update",
    method: "post",
    data: data
  });
}
